package com.example.lilei.Loves;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;

import com.example.lilei.Fragments.Love_10Fragment;
import com.example.lilei.Fragments.Love_11Fragment;
import com.example.lilei.Fragments.Love_12Fragment;
import com.example.lilei.Fragments.Love_1Fragment;
import com.example.lilei.Fragments.Love_2Fragment;
import com.example.lilei.Fragments.Love_3Fragment;
import com.example.lilei.Fragments.Love_4Fragment;
import com.example.lilei.Fragments.Love_5Fragment;
import com.example.lilei.Fragments.Love_6Fragment;
import com.example.lilei.Fragments.Love_7Fragment;
import com.example.lilei.Fragments.Love_8Fragment;
import com.example.lilei.Fragments.Love_9Fragment;
import com.example.lilei.R;

import java.util.ArrayList;
import java.util.List;


public class Love_2Activity extends FragmentActivity {
    private ViewPager vp;
    private Fragment L1 = new Love_1Fragment();
    private Fragment L2 = new Love_2Fragment();
    private Fragment L3 = new Love_3Fragment();
    private Fragment L4 = new Love_4Fragment();
    private Fragment L5 = new Love_5Fragment();
    private Fragment L6 = new Love_6Fragment();
    private Fragment L7 = new Love_7Fragment();
    private Fragment L8 = new Love_8Fragment();
    private Fragment L9 = new Love_9Fragment();
    private Fragment L10 = new Love_10Fragment();
    private Fragment L11 = new Love_11Fragment();
    private Fragment L12 = new Love_12Fragment();
    private List<Fragment>fragmentList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_love_2);
        initData();
        vp = (ViewPager) findViewById(R.id.Love_vp);
        vp.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    }
    private void initData(){
        fragmentList = new ArrayList<>();
        fragmentList.add(L1);
        fragmentList.add(L2);
        fragmentList.add(L3);
        fragmentList.add(L4);
        fragmentList.add(L5);
        fragmentList.add(L6);
        fragmentList.add(L7);
        fragmentList.add(L8);
        fragmentList.add(L9);
        fragmentList.add(L10);
        fragmentList.add(L11);
        fragmentList.add(L12);

    }
    class MyPagerAdapter extends FragmentPagerAdapter{

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }
    }
}
